<include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<script src="http://img1.isou365.cn/paimai/yunying/js/city.js" type="text/javascript"></script>
<style>
    .xuanzhe ul li .menDao1{width:300px;}
    .xuanzhe ul li .menDao1 a{display:block;background:#cecece;color:#303030;float:left;width:36px; text-align:center;height:20px; line-height:20px; cursor:pointer;}
    .xuanzhe ul li .menDao1 .menHover{ background:#20ab4f;color:#fff;}
</style>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="shgl.4s店回车"/>
    <div class="mianR">
        <div class="listBox">
            <div class="yuList">
                <h3 class="cha">4S店回车详情</h3>
                <div class="car_info">
                    <div class="car_no"><span style="font-size:14px;">拍卖单号：<b>{$detail.order_no}</b></span></div>
                    <table border="1" width="100%">
                        <tbody>
                        <tr>
                            <td colspan="4" style="background-color:#c1c1c1;font-size:14px;"><span>评估师信息</span></td>
                        </tr>
                        <tr>
                            <td width="11%" style="color:#898b8a;">评估师姓名</td>
                            <td width="39%">{$detail.checker_name}</td>
                            <td width="11%" style="color:#898b8a;">评估师电话</td>
                            <td width="39%">{$detail.checker_phone}</td>
                        </tr>
                        </tbody>
                    </table>

                    <table border="1" width="100%" style="margin-top:10px;">
                        <tbody>
                        <tr>
                            <td colspan="4" style="background-color:#c1c1c1;font-size:14px;">
                                <span>车辆信息</span>
                                <span style="float: right;margin-right: 20px;"><a style="color: #0000FF;text-decoration: underline;" href="/Car/report/car_id/{$detail.car_id}" target="_blank">检测报告</a></span>
                            </td>
                        </tr>
                        <tr>
                            <td width="11%" style="color:#898b8a;">车型</td>
                            <td width="39%">{$detail.model}</td>
                            <td width="11%" style="color:#898b8a;">排放标准</td>
                            <td width="39%">{$detail.emission}</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">初登日期</td>
                            <td>{$detail.first_reg_date}</td>
                            <td style="color:#898b8a;">颜色</td>
                            <td>{$detail.car_color}</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">表显里程</td>
                            <td>{$detail.pointer_mileage}万公里</td>
                            <td style="color:#898b8a;">车况级别</td>
                            <td>{$detail.composite_state}{$detail.accident_level}</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">车辆注册地</td>
                            <td>{$detail.first_reg_city}</td>
                            <td style="color:#898b8a;">车架号</td>
                            <td>{$detail.vin}</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">车牌号</td>
                            <td>{$detail.plate_prefix}{$detail.plate_suffix}</td>
                            <td style="color:#898b8a;">过户限制</td>
                            <td>{$detail.transfer_limit}</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">渠道来源</td>
                            <td>
                                <if condition="$detail.comefrom neq ''">
                                    <?php if(empty($detail['comefrom_url'])):?>
                                    {$detail.comefrom}
                                    <?php else: ?>
                                    <a href="{$detail.comefrom_url}" target="_blank" rel="noreferrer">{$detail.comefrom}</a>
                                    <?php endif;?>
                                    <else/>
                                    未知
                                </if>
                            </td>
                            <td style="color:#898b8a;">所在地</td>
                            <td>{$detail.location_area}</td>
                        </tr>
                        </tbody>
                    </table>
                    <table border="1" width="100%" style="margin-top:10px;">
                        <tbody>
                        <tr>
                            <td colspan="4" style="background-color:#c1c1c1;font-size:14px;"><span>拍卖信息</span></td>
                        </tr><tr>
                            <td width="11%" style="color:#898b8a;">竞拍结束时间</td>
                            <td width="39%">{$detail.bidding_end_time}</td>
                            <td width="11%" style="color:#898b8a;">拍卖最高价</td>
                            <td width="39%">{:format_money($detail['highest_price'])}元</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">保留价</td>
                            <td>{$detail.reserve_price}元</td>
                            <td style="color:#898b8a;">
                                <if condition="$detail.is_consult eq 1">磋商<else/>确认</if>成交价
                            </td>
                            <td>{:format_money($detail['owner_trade_price'])}元</td>
                        </tr>
                        <tr>
                            <td style="color:#898b8a;">公司补贴</td>
                            <td><?php echo $detail['company_subsidies'] > 0 ? $detail['company_subsidies']."元" : "无" ;?></td>
                            <td style="color:#898b8a;"></td>
                            <td></td>
                        </tr>
                        </tbody>
                    </table>
                    <table border="1" width="100%" style="margin-top:10px;">
                        <tbody>
                        <tr>
                            <td colspan="4" style="background-color:#c1c1c1;font-size:14px;">
                                <span>
                                    付款信息（{$detail.pay_status_name}<if condition="$detail.pay_status_code eq 21">100%）<elseif condition="$detail.pay_status_code eq 22" />50%）<else/>）</if>
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td width="11%" style="color:#898b8a;">付款人</td>
                            <td width="39%">
                                {$detail.pay_man}
                            </td>
                            <td width="11%" style="color:#898b8a;">付款时间</td>
                            <td width="39%">
                                {$detail.pay_time}
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <if condition="$detail.return_check_status eq 1">
        <div class="shop_details">
            <ul>
                <li>
                    <span>*交付门店</span>
                    <em>
                        <select id="delive_store" >
                            <option value="0">请选择交付门店</option>
                            <?php foreach($stores as $key=>$vs):?>
                                <option value="{$key}">{$vs}</option>
                            <?php endforeach;?>
                        </select>
                    </em>
                </li>
                <li class="come_on">
                    <span>*加油要求</span>
                    <em data-id="0">不加油</em>
                    <em data-id="30">30元</em>
                    <em data-id="50">50元</em>
                    <em data-id="80">80元</em>
                    <em data-id="100">100元</em>
                    <input id="refuel_demand" type="hidden" value="">
                </li>
                <li>
                    <span>*代驾公司</span>
                    <em><input id="driver_company" type="text" value="" placeholder="请输入代驾公司"></em>
                </li>
                <li>
                    <span>*代驾姓名</span>
                    <em><input id="driver_name" type="text" value="" placeholder="请输入代驾姓名"></em>
                </li>
                <li>
                    <span>*代驾电话</span>
                    <em><input id="driver_phone" type="text" value="" placeholder="请输入代驾电话"></em>
                </li>
                <li>
                    <span>*代驾出发时间</span>
                    <em><input id="depart_time" type="text" name="trace_start_time" value="" placeholder="请选择代驾出发时间" readonly="" class="driving_time"></em>
                </li>
                <li><span>手续</span>
                    <em class="procedures">
                        <?php foreach($procedures as $pk=>$p):?>
                        <label for="CheckboxGroup1_{$pk}"><input type="checkbox" name="procedures" value="{$p}" id="CheckboxGroup1_{$pk}">{$p}</label>
                        <?php endforeach;?>
                    </em>
                </li>
                <li>
                    <span>车钥匙</span>
                    <em><input id="carkey" type="text" value="" placeholder="请输入钥匙数量"><i>把</i></em>
                </li>
                <li>
                    <span>开票要求</span>
                    <em><input id="invoice" type="text" value="" placeholder="请输入开票价"> <i>元</i></em>
                </li>
                
                <li>
                    <span>备注</span>
                    <textarea id="remark" class="remarks_text"></textarea>
                </li>
            </ul>
        </div>

        <h3 class="cha">手续上传要求</h3>
        <div class="transfer-want">
            <div class="transfer-front clearfix">
                <dl class="clearfix" style="height: 310px;">
                    <dt style="height: 310px;">
                        <span style="margin-top: 134px;">过户前</span>
                    </dt>
                    <dd>
                        <ul >
                            <?php foreach($procedures_before as $pb):?>
                            <li data-id="1" class="clearfix">
                                <span>{$pb.value}</span>
                                <input type="hidden" value="{$pb.id}">
                                <input type="button" data-id="1" value="照片" >
                                <input type="button" data-id="2" value="扫描件">
                            </li>
                            <?php endforeach;?>
                        </ul>
                    </dd>
                </dl>
                <dl class="clearfix" style="margin-left:25px;">
                    <dt style="height: 310px;"><span style="margin-top: 134px;">过户后</span></dt>
                    <dd>
                        <ul>
                            <?php foreach($procedures_after as $pa):?>
                            <li data-id="2" class="clearfix">
                                <input type="hidden" value="{$pb.id}">
                                <span>{$pa.value}</span>
                                <input type="button" data-id="1" value="照片" >
                                <input type="button" data-id="2" value="扫描件">
                            </li>
                            <?php endforeach;?>
                        </ul>
                    </dd>
                </dl>
            </div>
        </div>
        <div class="yongBtn">
            <input id="submitForm" type="button" value="确定" class="queding">
            <input type="button" onclick="history.back();" class="quxiao" value="返回">
        </div>
      </if>
    </div>
    <div class="clear"></div>
</div>
<script>
    $(document).ready(function(){

        //新加的js功能效果
        var oH=$(".transfer-front dl:last-of-type").outerHeight();
        $(".transfer-front dl:first-child").css("height",oH+"px");
        $(".transfer-front dl dt").css("height",oH+"px");
        var oSh=$(".transfer-front dl dt span").height();
        $(".transfer-front dl dt span").css("marginTop",(oH-oSh)/2+"px");
        $(".transfer-front dl dd ul li input").on("click",function(){
            $(this).toggleClass("current");
        })
        var num=0;

        $(".transfer-front-list ul li").on("click",function(){
            $(".transfer-front-list ul li").removeClass("current");
            $(this).addClass("current");
            var index=$(".transfer-front-list ul li").index(this);
            var num=index;
            $(".transfer-front-content .transfer-front-tu").eq(num).show().siblings().hide();
        })

        $(".transfer-front-list1 ul li").on("click",function(){
            $(".transfer-front-list1 ul li").removeClass("current");
            $(this).addClass("current");
            var index=$(".transfer-front-list1 ul li").index(this);
            var num=index;

            $(".transfer-front-content .transfer-front-tu1").eq(num).show().siblings().hide();
        })
        $(".fork").click(function(){
            $(this).css("display","none");
            $("#uploader").hide();
            $(".yunBei").css("display","none");
        })
        $(".shibai").css("zIndex","9999999");
        $(".yunBei").css("zIndex","99998");
        //新加的js功能效果结束
        $(".driving_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true
        });

        $(function () {
            $("#delive_store").select2();
        });

        $(".shop_details ul .come_on em").click(function(){
            if($(this).hasClass("current")){
                $(this).removeClass("current");
            }else{
                $(".shop_details ul .come_on em").removeClass("current");
                $(this).addClass("current");
                $("#refuel_demand").val($(this).attr('data-id'));
            }
        });

        $('#submitForm').click(function() {
            var delive_store = $("#delive_store").val();
            if(delive_store==0){
                shibai_alert2("请选择交付门店");
                return;
            }
            var refuel_demand = $('#refuel_demand').val();
            if(refuel_demand==''){
                shibai_alert2("请选择加油要求");
                return;
            }
            var driver_company = $("#driver_company").val();
            if(driver_company==''){
                shibai_alert2("请输入代驾公司");
                return;
            }
            var driver_name = $("#driver_name").val();
            if(driver_name==''){
                shibai_alert2("请输入代驾姓名");
                return;
            }
            var driver_phone = $("#driver_phone").val();
            if(driver_phone==''){
                shibai_alert2("请输入代驾电话");
                return;
            }
            var depart_time = $("#depart_time").val();
            if(depart_time==''){
                shibai_alert2("请选择代驾出发时间");
                return;
            }
            var procedureObj = new Array();
            $("input:checked[name=procedures]").each(function() {
                procedureObj.push($(this).val());
            });
            var procedure = procedureObj.join("、");
            if(procedure==''){
                shibai_alert2("请选择手续");
                return;
            }
            var carkey = $("#carkey").val();
            var invoice = $("#invoice").val();
            var remark = $("#remark").val();
            var transfer = [];
            $(".transfer-want li").each(function(index, el) {
                var obj = {},
                        $el = $(el),
                        imgType = 0;

                $el.find("input.current").each(function(index2, el2) {
                    imgType += $(el2).data('id');
                });
                if(imgType === 0){return true; }

                obj.transfer_status = $el.data("id");
                obj.certificate_id = $el.find("input[type='hidden']").val();
                obj.certificate_name = $el.find("span").text();
                obj.certificate_image_type = imgType;

                // 放到数组里
                transfer.push(obj);
            });

            var postData = {
                "order_id":"{$detail.order_id}",
                'delive_store':delive_store,
                "refuel_demand":refuel_demand,
                "driver_company":driver_company,
                "driver_name":driver_name,
                "driver_phone":driver_phone,
                "depart_time":depart_time,
                "procedure":procedure,
                "carkey":carkey,
                "invoice":invoice,
                "procedures_upload":transfer,
                "remark":remark
            };
            $(".yunBei").css("display",'block');
            $(".loading").fadeIn();
            $.post('/CarReturn/commit_return',postData,function (data) {
                if(data.code!=200){
                    $(".loading").hide();
                    shibai_alert2(data.msg,1500);
                    return false;
                }
                btn_alert("操作成功",1500,function () {
                    window.location.href="/CarReturn/index";
                });
            },'json');
        });
    });
</script>
<include file="Public/foot" />